package com.joker.yuwu;

import com.joker.repository.CreatZhanHui;
import net.sf.json.JSONObject;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;

@WebServlet("/creatzh")
public class CreatZh extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        super.doGet(req, resp);
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/json; charset=utf-8");
        String s1=req.getParameter("userid");
        String s2=req.getParameter("zhname");
        String s3=req.getParameter("zgname");
        String s4=req.getParameter("xinxi");
        System.out.println("输出信息"+s1);
        Date t1= new Date(1);
        Date t2= new Date(1);
        CreatZhanHui c1=new CreatZhanHui();
        boolean jieguo=c1.creat(s1,s2,s3,s4,t1,t2);
        JSONObject obj=new JSONObject();
        obj.put("data",jieguo);
        resp.getWriter().write(obj.toString());

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        super.doPost(req, resp);
        req.setCharacterEncoding("utf-8");
        String s1=req.getParameter("username");
        String s2=req.getParameter("zgname");
        String s3=req.getParameter("zhname");
        String s4=req.getParameter("xinxi");
        System.out.println("输出信息"+s1);
        Date t1= new Date(1);
        Date t2= new Date(1);
        CreatZhanHui c1=new CreatZhanHui();
        c1.creat(s1,s2,s3,s4,t1,t2);

    }
}
